import java.util.Objects;

public class Worker {   //定义一个Worker类型

    private String name; // 姓名
    private int age; // 年龄
    private double salary;   //工资

    //无参方法
    public Worker() {
    }

    //有参方法
    public Worker(String name, int age, double salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    //重写 equals 方法
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
        {
            return true;
        }
        if (obj == null)
        {
            return false;
        }
        if(obj instanceof Worker)
        {
            Worker c=(Worker)obj;
            return this.name.equals(c.name) && this.age==c.age && this.salary==c.salary;
        }
        return false;
    }

    //重写 toString 方法
    @Override
    public String toString() {
        return "Worker{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, salary);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    //work 方法
    public void work() {
        System.out.println( name + "正在工作");
    }
}
